<?php
include'conn.php';
$xingqv="";
foreach($_POST['hobby'] as $item)
{
    switch($item)
    {
        case 1:
            $xingqv.="篮球 ";
            break;
        case 2:
            $xingqv.="足球 ";
            break;
        case 3:
            $xingqv.="游泳 ";
            break;
                
    }
}
$sql = "INSERT INTO students(uname,upwd,realname,unumber,gender,class,hobby,mark,create_time) 
VALUES('".$_POST['uname']."',
'".$_POST['upwd']."',
'".$_POST['realname']."',".$_POST['unumber'].",
".$_POST['gender'].",".$_POST['class'].",'".$xingqv."','".$_POST['mark']."',".time().")";

//echo $sql;

if($conn->query($sql)===TRUE)
{
    echo"插入成功";

}
else
{
    echo"插入失败：".$sql."<br>".$conn->error;
}
echo ",<a href='index.php'>返回首页</a>";
$conn->close();

?>